import { createRouter, createWebHistory } from "vue-router";
import routerB from "./client";
const routes = [...routerB]; //可导入多个 [...routerA,...routerB]
const router = createRouter({
  history: createWebHistory(),
  routes,
});
//挂载路由导航守卫
router.beforeEach((to, from, next) => {
  // 如果是要前往的页面不存在，就重定向到首页
  if (to.matched.length === 0) {
    next("/");
  } else {
    next();
  }
});
export default router;
